package com.hbut.bili.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hbut.bili.entity.Video;
import com.hbut.bili.service.VideoService;

public class VideoAddServlet extends HttpServlet {
	
	private VideoService videoService = new VideoService();

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		
		Video video = new Video();
		video.setAid(Long.parseLong(request.getParameter("aid")));
		video.setBvid(request.getParameter("bvid"));
		video.setCid(request.getParameter("cid"));
		video.setPic(request.getParameter("pic"));
		video.setTitle(request.getParameter("title"));
		video.setDescript(request.getParameter("descript"));
		try {
			videoService.inserVideo(video);
		} catch (Exception e) {
			e.printStackTrace();
		}
		request.getRequestDispatcher("view/videoAddSuccess.jsp").forward(request, response);
	}
	
}
